/*
 * Powered By [d2dcloud.net]
 * Since 2016 - 2020
 */
package net.d2dcloud.service.impl;

import net.d2dcloud.entity.Groupon;
import net.d2dcloud.core.tk.service.impl.BaseServiceImpl;
import net.d2dcloud.service.GrouponService;

import org.springframework.stereotype.Service;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.util.Sqls;

import java.util.List;

/**
 * @author codeGen v0.0.1
 * @version 1.0
 * @since 1.0
 */
@Service
public class GrouponServiceImpl extends BaseServiceImpl<Groupon> implements GrouponService {


  @Override
  public Groupon selectById(Object id) {
    Groupon groupon = new Groupon();
    groupon.setId(id.toString());
    groupon.setDeleted(false);
    return selectOne(groupon);
  }

  @Override
  public Integer deleteById(String id) {
    Groupon groupon = new Groupon();
    groupon.setDeleted(true);
    Example ex = Example.builder(Groupon.class)
        .where(Sqls.custom()
            .andEqualTo("id", id))
        .build();
    return super.updatedByExampleSelective(groupon, ex);
  }

  @Override
  public List<Groupon> selectByIds(List<String> ids) {
    Example ex = Example.builder(Groupon.class)
        .where(Sqls.custom()
            .andIn("id", ids)
            .andEqualTo("deleted", false))
        .build();
    return super.selectByExample(ex);
  }
}